// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	2/17/2015 9:18:25 PM				
// -----------------------------

#ifndef _CommandHandler_inl
#define _CommandHandler_inl

namespace Flow
{

	template<typename T>
	CommandHandler<T>::CommandHandler()
	{

	}
	template<typename T>
	CommandHandler<T>::~CommandHandler()
	{
		while (!m_CommandQueue.empty())
		{
			T* lpCommand = m_CommandQueue.front();
			m_CommandQueue.pop();

			delete lpCommand;
		}
	}

	template<typename T>
	void CommandHandler<T>::PushCommand(T* lpCommand)
	{
		m_CommandQueue.push(lpCommand);
	}
	template<typename T>
	void CommandHandler<T>::ProcessCommands(ProcessOption::Enum option)
	{
		if (m_CommandQueue.empty())
			return;

		if (option == ProcessOption::ProcessOne)
		{
			T* lpCommand = m_CommandQueue.front();
			m_CommandQueue.pop();

			this->ProcessSingleCommand(lpCommand);
			delete lpCommand;
		}
		else if (option == ProcessOption::ProcessAll)
		{
			while (!m_CommandQueue.empty())
			{
				T* lpCommand = m_CommandQueue.front();
				m_CommandQueue.pop();

				this->ProcessSingleCommand(lpCommand);
				delete lpCommand;
			}
		}
	}

}

#endif